package net.oschina.app.fragment.explore;

import android.content.Intent;

import net.oschina.app.adapter.explore.FriendsRircleAdapter;
import net.oschina.app.adapter.explore.RecentlyEventAdapter;
import net.oschina.app.base.BaseListAdapter;
import net.oschina.app.base.BaseListFragment;
import net.oschina.app.bean2.ExploreEventBean;
import net.oschina.app.protocol.AccessProtocol;
import net.oschina.app.protocol.explore.RecentlyEventProtocol;
import net.oschina.app.ui.activity.explore.EventDatilsActivity;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 张运湘 on 2017/1/14.
 */

public class RecentlyEventFrament extends BaseListFragment {
    private RecentlyEventProtocol mRecentlyEventProtocol ;
    private List<ExploreEventBean.EventBean> mEventBeanList = new ArrayList<>();

    @Override
    protected List parseData(Object body) {
         mEventBeanList = ((ExploreEventBean) body).getEvents();
        return mEventBeanList;
    }

    @Override
    protected AccessProtocol getProtocol() {
          mRecentlyEventProtocol = new RecentlyEventProtocol();
        return mRecentlyEventProtocol;
    }

    @Override
    protected BaseListAdapter getAdapter() {
        RecentlyEventAdapter  recentlyEventAdapter = new RecentlyEventAdapter(getActivity());
        recentlyEventAdapter.setItemOnclickListener(new FriendsRircleAdapter.setItemOnclickListener() {
            @Override
            public Void toDetilactivity() {
                Intent intent = new Intent(getContext(), EventDatilsActivity.class);
                startActivity(intent);
                return null;
            }
        });
        return recentlyEventAdapter;
    }

}
